package com.boolib.http.sign.wrapper;


import com.boolib.http.core.abstracts.AbstractHttpRequestReusableStreamWrapper;
import com.boolib.http.core.exception.ExceptionFactory;

import com.boolib.http.sign.model.MessageBody;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


/**
 * @author wfq
 */
public class DecryptBodyRequestWrapper extends AbstractHttpRequestReusableStreamWrapper {


    public DecryptBodyRequestWrapper(HttpServletRequest request) throws IOException {
        super(request);
    }



    public MessageBody getMessageBody() {
        try {
            return new ObjectMapper().readValue(this.decodeStreamData, MessageBody.class);
        }catch (IOException ex){
            throw ExceptionFactory.ofCheck("E10000","签名失败");
        }
    }


}
